import { Select } from 'antd';
import React from 'react';

const { Option } = Select;

export const transferOption = (arrayData: Array<any> = [], keyValue = ['value', 'label']) =>
  arrayData.map(item => <Option key={item[keyValue[0]]}>{item[keyValue[1]]}</Option>);

export const transferDefaultOption = (
  arrayData = [],
  keyValue = ['value', 'label'],
  defaultOption = ['', '请选择'],
) => {
  const optionList = [];
  optionList.push(<Option key={defaultOption[0]}>{defaultOption[1]}</Option>);
  optionList.push(transferOption(arrayData, keyValue));
  return optionList;
};
